<template>
  <div>
    <topper></topper>
    <index-header :query="query"></index-header>
    <search-nav-box></search-nav-box>
    <search-wrapper :query="query" :total="GoodList.length"></search-wrapper>
    <serach-filter-box :query="query"></serach-filter-box>
    <serach-item-list :list="GoodList" ref="serachItemList"></serach-item-list>
    <index-fatfooter></index-fatfooter>
  </div>
</template>
<script>
import '../../assets/statics/css/search-goods.css'
import '../../assets/statics/js/icheck/style.css'
import IndexHeader from '../index/components/IndexHeader'
import Topper from '../../components/Topper'
import IndexFatfooter from '../index/components/IndexFatfooter'
import SearchNavBox from './components/SearchNavBox'
import SearchWrapper from './components/SearchWrapper'
import SerachFilterBox from './components/SearchFilterBox'
import SerachItemList from './components/SearchItemList'
import http from '../../base/api/http'
export default {
  name: 'SearchGood',
  components: {
    Topper,
    IndexHeader,
    IndexFatfooter,
    SearchNavBox,
    SearchWrapper,
    SerachFilterBox,
    SerachItemList
  },
  data () {
    return {
      GoodList: [],
      query: {
        commodityName: null,
        brandId: null,
        categoryId: null
      }
    }
  },
  methods: {
    findAll () {
      http.requestGet('/java/api/commodity/findCommodityList', {
        'commodityName': this.query.commodityName,
        'brandId': this.query.brandId,
        'categoryId': this.query.categoryId
      }).then((res) => {
        if (res.status === 0) {
          this.GoodList = res.data
          this.$refs.serachItemList.handleCurrentChange(1)
        }
      })
    }
  },
  computed: {
    getCommodityName: function () {
      return this.query.commodityName
    }
  },
  watch: {
    getCommodityName (val, oldVal) {
    }
  },
  mounted () {
    this.query.commodityName = this.$route.query.commodityName
    this.query.brandId = this.$route.query.brandId
    this.query.categoryId = this.$route.query.categoryId
    console.log(this.query.commodityName)
    this.findAll()
  }
}
</script>
<style>

</style>
